//
//  EntertainmentViewCell.m
//  Product_NEWS
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 FCH. All rights reserved.
//
#define WIDTH ([UIScreen mainScreen].bounds.size.width / 375)
#define HEIGHT ([UIScreen mainScreen].bounds.size.height / 667)
#import "EntertainmentViewCell.h"
#import "NightModeHandle.h"
#import "UIImageView+WebCache.h"

@interface EntertainmentViewCell()
@property (nonatomic, retain) UIImageView *headImageView;
@property (nonatomic, retain) UIImageView *titleImageView;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *dateLabel;
@property (nonatomic, retain) UILabel *timeLabel;
@end

@implementation EntertainmentViewCell

-(void)dealloc{
    [_headImageView release];
    [_titleImageView release];
    [_titleLabel release];
    [_timeLabel release];
    [_dateLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self createSubViews];
    }
    
    return self;
}

-(void)createSubViews
{
    self.contentView.backgroundColor = [NightModeHandle shareNightModeHandle].allViewColor;
    
    //列表图片
    self.headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10*WIDTH, 8*HEIGHT, 120*WIDTH, 84*HEIGHT)];
    self.headImageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:self.headImageView];
    
    //标题
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(135*WIDTH, 6*HEIGHT, 230*WIDTH, 65*HEIGHT)];
    self.titleLabel.font = [UIFont systemFontOfSize:16*SCREEN_WIDTH];
    self.titleLabel.textColor = [NightModeHandle shareNightModeHandle].titleColor;
    self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.titleLabel.numberOfLines = 2;
    
    self.titleLabel.backgroundColor = [NightModeHandle shareNightModeHandle].allViewColor;
    [self.contentView addSubview:self.titleLabel];
    
    //日期
    self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(220*WIDTH, 70*HEIGHT, 50*WIDTH, 20*HEIGHT)];
    self.dateLabel.font = [UIFont systemFontOfSize:14*SCREEN_WIDTH];
    self.dateLabel.backgroundColor = [NightModeHandle shareNightModeHandle].allViewColor;
    self.dateLabel.text = @"日期:";
    self.dateLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.dateLabel];
    //时间
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(270*WIDTH, 70*HEIGHT, 100*WIDTH, 20*HEIGHT)];
    self.timeLabel.font = [UIFont systemFontOfSize:14*SCREEN_WIDTH];
    self.timeLabel.backgroundColor = [NightModeHandle shareNightModeHandle].allViewColor;
    self.timeLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.timeLabel];
}

-(void)setModel:(EntertainmentModel *)model{
    
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    self.titleLabel.text = self.model.title ;
    self.timeLabel.text = self.model.date;
    NSURL *url = [NSURL URLWithString:self.model.ImageUrl];
    [self.headImageView sd_setImageWithURL:url ];
    
    
}


    
    
    




@end
